import axios from 'axios';

// 请求拦截
axios.interceptors.request.use(
	config => {
		if(config.url.indexOf("upload") >= 0){
			config.headers = "multipart/form-data";
		}
		return config;
	},
	err => {
		return Promise.error(err);
	}
);

// 响应拦截
axios.interceptors.response.use(response => {
	if(response.data.code === 200){
		return Promise.resolve(response.data);
	} else {
		return Promise.reject(response.data);
	}
});

export default axios;